export function convertDepartments(departments) { //部门数组转换方法
	if (!Array.isArray(departments)) {
		return [];
	}
	return departments.map(dept => ({
		id: dept.deptId,
		label: dept.deptName,
		parentId: dept.parentId
	}));
}

export function sievePersonnel(departments) { //部门数组转换方法
	if (!Array.isArray(departments)) {
		return [];
	}
	return departments.map(dept => ({
		id: dept.deptId,
		label: dept.nickName,
		jobNumber: dept.jobNumber
	}));
}


export function convertDepartmentsPublic(departments) { //字典数组转换方法
	if (!Array.isArray(departments)) {
		return [];
	}
	return departments.map(dept => ({
		id: dept.dictValue,
		label: dept.dictLabel
	}));
}

export function validatePhone(phone) { //校验手机号
	const cleaned = phone.replace(/\s/g, '');
	return /^\d{11}$/.test(cleaned);
}

export function validateIdCard(idCard) { //身份证校验
	// 去除所有空格后验证长度是否为18位
	const cleaned = idCard.replace(/\s/g, '');
	return cleaned.length === 18;
}